package com.bci.internal.engine.bcibpmengine.validator;


import com.bci.internal.engine.bcibpmengine.utils.BCValidationUtils;
import com.bci.internal.engine.bcibpmengine.validator.annotation.PhoneNumber;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

/**
 *  手机号码验证器
 * @author jzwu
 * @since 2021/4/4 0004
 */
public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {

    @Override
    public boolean isValid(String phoneNumber, ConstraintValidatorContext ctx) {
        if (phoneNumber == null || phoneNumber.isEmpty()) {
            return true;
        }
        return BCValidationUtils.isPhoneNumberLegal(phoneNumber);
    }
}
